Repository navigation
feat(staged): end a saved note turn cleanly with a hidden "Done" and the note card - #1092
Merged
Merged
Conversation
…no stored body A note session's turn that ended without a `write_note` call was always followed by an automatic prompt forcing the call. The prompt exists so an empty note is not stored, but it also fired on a note that already had a body. A chat question on such a note then cost an extra agent turn and a forced republish. The republish stamped the note after the last chat message, so the chat pane's "Ask for the note to be updated" button could never appear. The decision now lives in a pure function, `note_write_followup_due`: the follow-up is sent only when the turn delivered nothing, the note has no stored body, and the run has its one attempt left. "Has a stored body" is the reading the draft seed already uses (`stored_note_seed`), through the new `stored_note_has_body`. A chat-only turn on an amended note reaches the hooks' existing "keep existing content" branch, so the note and its timestamp stay as they are. A remote amendment whose outbox read fails gets no follow-up turn either. The read error is still remembered, and the read after the run settles it (`completed_run_outbox_unread`). Tests: a table for the decision, and a store-backed test of a chat-only turn on fresh and amended branch and project notes. The fallback section of docs/note-delivery.md and its manual check list describe the new rule. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The chat pane shows a note session's `write_note` call as a "Saved note" row named after the note, in place of a generic "Ran" row. It finds the call by tool name through `isWriteNoteToolName`. That matcher knew Claude Code's `mcp__staged__write_note` and Goose's `staged: write note`. Codex titles the call `mcp.staged.write_note`, which the matcher rejected, so a Codex note session showed the call as a plain command row with no title or next steps. The matcher now strips an `mcp.` prefix as well as `mcp__` before it checks for the `staged` server and the `write_note` tool. The server check is unchanged, so `mcp.other.write_note` is still not a note row. This is also what the planned filter for the hidden "Done" message keys on: it looks for a completed `write_note` call, and without this change it could never match a Codex turn. Tests: the name table in noteToolCall.test.ts now labels each spelling and adds the Codex form, case and padding variants, and rejections for other servers, other tools, a doubled prefix and a name inside a longer title. `writeNoteToolCall` reads a Codex call, and the view-model test renders the Codex form as a note row. docs/note-delivery.md lists the Codex spelling beside the other two. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A note session publishes its note with the `write_note` tool and then
keeps writing: Claude adds a recap after every saved call. The plan is to
have the tool result ask the agent to close the turn with the one word
"Done", and to hide that message in the chat pane, since the "Saved note"
row above it already says what happened. This commit is the hiding half.
It is inert until the wording changes, because no agent sends a bare
"Done" today.
The rule lives in a new pure module, `noteDoneMessage.ts`.
`isNoteDoneText` accepts the trimmed text when it is "done" in any case,
optionally inside one pair of `**`, `*`, `_`, backticks or quotes, and
with one trailing `.` or `!`. Anything more is real text: `Done ✅`, a
sentence that starts with the word, or an answer whose last line is
`Done`.
`hiddenNoteDoneMessageIds` takes the transcript groups and returns the
assistant messages to hide. A message is hidden only when:
- the nearest earlier group is a tool group whose last `write_note` item
resolved to `completed`, found with `writeNoteToolCall` and not by its
label, so a rejected, running or interrupted call hides nothing and a
remote call completed from the outbox counts as saved;
- every assistant message between that group and the end of the turn is
a bare "Done", so a second one from a background wake is hidden too
and a recap after the first shows both;
- the turn ends there, at the next user message or the end of the
transcript, not at another tool call.
Other items in the tool group do not matter, which covers the review
item Codex completes after the call and a shell call Claude issues
beside it. The rule fails open: on any mismatch the message renders
whole, exactly as written. The row stays stored either way.
`SessionChatPane` derives `renderedGroups` from `grouped` and iterates
that. The plan put the check inside the assistant branch of the group
loop. That would leave an empty `.transcript-group` wrapper, which takes
a second 12px gap in the column and is picked up as a scroll anchor, and
an `{#if}` around the wrapper would stop new messages sliding in. So the
hidden group is left out of the list. `lastGroupIndex` follows the
rendered list. The rule runs on every rebuild, so a message that grows
past the word while streaming comes back with all of its text.
Tests: a table for `isNoteDoneText`. `hiddenNoteDoneMessageIds` is run
over groups built by `buildAcpTranscriptGroups` for a match in each
bridge's spelling, a rejected call, a running call, an interrupted call,
a tool call after the text, more text after "Done", a reply between the
call and "Done", an answer ending in a `Done` line, two "Done" messages,
Codex's extra item, a remote call completed from the outbox, several
turns, and another server's `write_note`. A component test mounts the
real pane with the real tool row and asserts the message is absent for
each bridge, present after a rejected or interrupted call, and back
again when more text or a tool call follows it.
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A note session publishes its note with the `write_note` tool and then keeps writing: Claude adds a recap after every saved call. 54c390b taught the chat pane to hide a bare "Done" that follows a saved call. This commit is the other half: the three texts the agent reads now ask for that message, so a saved turn ends with nothing shown under the "Saved note" row. The wording is the combined one from the live runs. It hid the most endings without losing an answer to a user's question. - Tool result, after the "Saved note" sentence: answer the user's question now if it is still unanswered, otherwise send a simple "Done" message with no other text. It is in `note_tool::saved_message` for local sessions and `savedMessage` in `staged-mcp.cjs` for Blox. - Tool description, last sentence: send "Done" after the saved result, and answer a question before making the call. It is in the `#[tool]` attribute, `WRITE_NOTE_DESCRIPTION` and the script's copy. - Session prompt, last paragraph of `note_delivery_guidance`: the same request, that Staged hides the message, and to answer a question in the reply before the call. `SERVER_VERSION` in the script goes from 6 to 7, since the tool's contract with the agent changed. The upload is gated on a checksum, so a workstation gets the new text on its next session, together with the app. The version history in docs/staged-mcp-on-blox.md lists version 7. Nothing else changes. A turn that ignores the wording renders as it does today, because the filter shows any text other than a bare "Done". Tests: - The pinned strings follow the new wording: the exact result text and the description's ending in note_tool.rs, the last paragraph of the guidance in every note prompt in session_commands.rs, and the script version in remote_staged_mcp.rs. - `saved_result_text_is_identical_for_local_and_remote_sessions` gives the local handler and the script the same title and draft and compares the two result texts, over titles and drafts with a heading mark, quotes, multi-byte characters, padding and a byte order mark. It needs node, like the other script tests. - noteDoneWording.test.ts reads note_tool.rs, staged-mcp.cjs and session_commands.rs as text. Each result text, each description and the session prompt must quote exactly one closing word, and it must be `NOTE_DONE_WORD`, which `isNoteDoneText` accepts. It also compares the instruction of the two result texts without node. Changing the word or the sentence on one side fails it. - The `write_note` result fixture in toolCallViewModel.test.ts carries the new text. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Since notes moved to the `write_note` tool, a note session's chat has had no "Note created" or "Note updated" card. The pane drew the card only for an assistant message that holds the old `---` separator, and the tool path never writes that text. With the closing "Done" hidden (54c390b), a saved turn now ends at the "Saved note" tool row, so a card under it would say the same thing twice. The completed call is therefore rendered as the card, in the row's place. The decision lives in a new pure module, `noteDeliveries.ts`, beside `noteFreshness.ts`. `listNoteDeliveries` reads the transcript groups and lists where a note was delivered: a `write_note` call that resolved to `completed`, or an assistant message with the separator, which is still the shape of a run with no tool and of every session recorded before it. The call is found by its tool name, not its label, and by its resolved status, so a remote call completed from the outbox counts. The first delivery in the transcript is "Note created" and later ones are "Note updated", across both shapes. This replaces `noteBearingMessageIds` in the pane. A call that was rejected, interrupted or is still running is not a delivery and keeps its tool row, with its title and details. The final-turn rule: in the final turn of a session that is no longer running, and when the pane is opened on its note, a saved call is a card only when `updatedAt` on the note is at or after the call row. The note is stored after the turn, so a turn that changed it stamps it later than its own call. An older note was not changed by that call: the agent republished an identical note, which keeps its timestamp, or the run failed before the note was stored. That call keeps its "Saved note" row and the "Ask for the note to be updated" button, which reads the same timestamp, shows under it. Calls of earlier turns are not compared. The final turn is everything after the last user message, as in the transcript builder. The comparison waits for the session to settle. The note cannot be stored before the run ends, and a run can wait on background work after the call, so a strict reading would hold the row for the whole turn and swap it at the end. While the session runs, the saved call is a card as soon as it completes. The button needs a completed session, so the card and the button still do not show together for one turn. `groupRichToolsByVerb` takes an optional predicate for items the caller renders on its own. The pane passes the card items, so two saved calls in a row are two cards and not one collapsed "Saved note" row. The deliveries object is kept across rebuilds that change no delivery, so tool groups are not re-evaluated on every poll tick. In the tool group the card keeps its own width and a 6px margin from the rows beside it. Tests: - noteDeliveries.test.ts runs the helper over groups built by `buildAcpTranscriptGroups`: each bridge's spelling, a rejected, cancelled, pending, running and interrupted call, a remote call completed from the outbox, another server's `write_note`, Codex's extra item, a rejected call and its retry, created and updated labels, the separator shape alone and mixed with calls, and a table for the final-turn rule that also checks the card against `shouldAskForNoteUpdate`. - SessionChatPane.noteCard.component.test.ts mounts the real pane with the real card and the real tool row. It asserts the card for each bridge, the two labels, a reply under the card, the kept row for a rejected and an interrupted call, two cards in a row, the row turning into the card when a running call completes, the text shape, and, with a note context, the card without the button, the row with the button, the swap when the note refreshes, and a running session that settles with the note unchanged. - SessionChatPane.noteDone.component.test.ts expects the card where it expected the "Saved note" row. - acpTranscript.test.ts covers the new grouping predicate. Not changed: the `---` scan still runs on assistant messages in a turn that holds a `write_note` call, and docs/note-delivery.md still describes the "Saved note" row. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A saved `write_note` call asks the agent to close its turn with the one word "Done" (ac9fc8b), and the chat pane hides that message (54c390b). Nothing forces the agent to comply. A model that stops following the wording goes back to writing a recap under the note card, and no test or error says so. This commit adds the two checks the plan asked for: a log line in the app, and an ignored test against a real agent. The log. After each settled turn of a note session, the run loop calls `note_done::log_settled_turn_note_done_drift`. It logs one info line, starting `note-done drift`, when the turn saved a note and did not end in a bare "Done". The line holds counts and lengths only: how many assistant messages followed the call, the length of the last one, whether that one ends in a "Done" line, and whether a tool call came after the text. A rising count of these lines means the wording has stopped working. The call sits after the outbox collection, so a remote note is in the slot, and before the Pikchr check, so a turn that goes on to a repair counts. The decision is `note_done_drift`, a pure function over the turn's stored rows, in the new `src-tauri/src/note_done.rs`. It follows the pane's rule: - The turn is everything after the last user row. A message steered in after the call starts a new turn and is not checked. - The turn saved a note when the submission slot is filled and the turn holds a `write_note` call. The slot alone outlives a turn. - After the last such call, the tool rows beside it are stepped over. Then at least one assistant message must follow, each must be a bare "Done", and the turn must end there. - A turn that ends at the call, with no closing message, is logged too. The log and the filter agree on what counts as "Done" and on which call is `write_note`. `note_done/rules.rs` holds Rust copies of the pane's `isNoteDoneText` and `isWriteNoteToolName`, with JavaScript's white space set. The cases for both rules moved out of the two TypeScript tests into `testStubs/noteDone.cases.json`, which the Rust tests and the vitest tests both run. A change to one side alone fails a test. The table gained rows for a no-break space, a byte order mark, a next-line character and a zero-width space, where `trim` differs between the two languages. The real-agent test. `real_bridge_saved_note_turn_ends_with_a_bare_done` in `crates/acp-client` is ignored by default, like the other real-bridge tests. It attaches the shipped `staged-mcp.cjs` as the `staged` MCP server, with a temporary home directory so nothing is written under `~/.staged`. The prompt asks for a short note and says nothing about how to end the turn, so the closing word comes from the tool's description and saved result alone. It asserts that the note was saved, that every row after the `write_note` call is a bare "Done" and there is at least one, and, for Claude, that the session settles as `ResponseComplete`. It compiles `note_done/rules.rs` by `#[path]`, so the agent is held to the rules the app ships. That file is kept free of dependencies for this. The real-bridge harness gained what the test needs: MCP servers and a finish predicate in `ConnectOptions`, tool title updates in the trace, and `rows_from` for the rows of part of a trace. `stored_tool_call_title` in the message writer is now `pub(crate)`, so the drift check reads a call's title the way it was stored. Tests: - note_done/tests.rs: both rules over the shared table; the drift decision for each bridge's spelling, every accepted and rejected text, a recap, a turn that ends at the call, an empty slot, a turn with no call, earlier turns, a steered message, other tool rows beside the call, a second "Done", a recap after "Done", an answer ending in a "Done" line, a tool call after the text, and two calls in one turn; the wording of the log line; and three store-backed tests with rows written by the real message writer. - noteDoneMessage.test.ts and noteToolCall.test.ts run the shared table. Not changed: docs/note-delivery.md, which a later commit updates. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… log docs/note-delivery.md still described note delivery as it was before this branch. It quoted the old `write_note` result text, said a saved call shows as a "Saved note" row, and did not mention the closing "Done" message, the note card or the drift log. This commit brings the doc in line with 8f98dd3, d4a9170, 54c390b, ac9fc8b, d49b05f and 1fee942. It changes no code. Passages brought up to date: - Tool contract: the result text is the shipped one, which asks for an answer to an open question or a bare "Done". A new paragraph says the call does not end the turn, since neither MCP nor ACP lets a tool do that, and that the response the message writer finishes after is now the "Done" message. - The draft file: `note_delivery_guidance` is described with its last paragraph, the request for "Done". The chat pane paragraph says a saved call is the note card, and names the rows that remain: "Saving note", "Note rejected", and "Saved note" under the final-turn rule. A remote call completed from the outbox is a saved call like any other. - Background hold: the response that ends a local hold is the "Done" message, and a second "Done" from background work is hidden. - Design decisions: the Stop entry names the note card and gives the shorter window after the call. - How to test manually: local step 1 expects the "Saving note" row to become the "Note created" card with nothing under it, step 6 expects the "Note rejected" row above the retry's card, and the Blox disconnect step waits for the card. - Automated coverage: the frontend entries name all three bridges and the grouping predicate. New text: - A section, "Ending a saved turn: the hidden "Done"": the three texts that make the request, why the result text says "answer it now", the rule in `noteDoneMessage.ts`, that it fails open, why the hidden group is left out of the rendered list, the readers that still see the stored row, and remote sessions. - "The note card": the two delivery shapes, the created and updated labels, calls that keep their row, the final-turn rule and its tie to the "Ask for the note to be updated" button, and why the comparison waits for the session to settle. - "The drift log": where the line is logged, an example line, a table of its endings, the decision in `note_done_drift`, and the one case where the log and the pane differ. It says what a rising count means. One line is not an error, because a turn that answers an open question after the call is logged too. A rising count means an agent or a new model writes after the saved call again. The steps to take are the ignored real-agent test, a change to all three texts together, and the Claude `PostToolUse` hook held in reserve. - Five design decisions: the hidden "Done" over a hard stop, hiding at render over dropping the row, showing a trailing `Done` line, keying the rule on the call, and the card in place of the row. - Manual steps 7 to 10 for the card and the button, a question in a note turn, drift, and the real-agent test, plus one sentence in the Blox list. - Automated coverage for the wording, the filter, the card, the follow-up rule and the drift log. The live-run counts and timings in the doc are the ones recorded in the plan note for this work. Checked with `node_modules/.bin/prettier --check docs/note-delivery.md`, run from apps/staged. Prettier realigned the two new tables and nothing else. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A note session publishes its note through the
write_notetool and then keeps writing: Claude adds a recap after every saved call, Codex calls were not even recognised as note rows, and the "Note created" / "Note updated" card never appeared on the tool path. This branch makes a saved note turn end cleanly in the chat pane.mcp.staged.write_note) alongside the Claude Code and Goose forms, so Codex note sessions render a "Saved note" row.write_notefollow-up to a note with no stored body. A chat-only turn on an amended note no longer forces a republish, so the "Ask for the note to be updated" button can appear.note_tool.rsand the Bloxstaged-mcp.cjs, server version 6 → 7) now ask for an answer to any open question, otherwise a bare "Done".noteDoneMessage.ts). The rule keys on a completedwrite_notecall, requires every following assistant message in the turn to be a bare "Done", and fails open on any mismatch.noteDeliveries.ts), with "Note created" for the first delivery and "Note updated" after; rejected, running and interrupted calls keep their row. In the final turn the card only replaces the row when the note'supdatedAtis at or after the call, so the update button and the card never show together.note_done::log_settled_turn_note_done_driftlogs onenote-done driftline when the turn saved a note but did not end in "Done". A rising count means the wording has stopped working.isNoteDoneText/isWriteNoteToolNamecases live intestStubs/noteDone.cases.jsonand are run by both the Rust and vitest suites, so the two sides cannot diverge silently.real_bridge_saved_note_turn_ends_with_a_bare_doneincrates/acp-clientdrives the shipped MCP script against a real bridge.docs/note-delivery.mddescribes the hidden "Done", the note card and the drift log.Test plan
cargo test -p acp-client --lib,src-tauritests, and vitest suites pass locally (two acp-client attach-cancel tests flaked once under load average > 60 and pass in isolation; they are untouched by this branch)noteDoneMessage,noteDeliveries,noteDoneWording,SessionChatPane.noteCard,SessionChatPane.noteDone,note_done/tests.rs,session_runner/tests/note_draft.rs🤖 Generated with Claude Code